#define DEBUG
#include <cstdio>
#include <cmath>

using namespace std;

const int maxn=100000;

class Card {
public:
  double center, dis;
};

void sort(Card *a, int l, int r) {
  int i=l, j=r;
  double mid[2] = {a[(l+r)/2].center, a[(l+r)/2].dis};
  Card temp;
  for (; i<=j; ) {
    for (; a[j].center>mid[0] || (a[j].center==mid[0] && a[j].dis>mid[1]); j--);
    for (; a[i].center<mid[0] || (a[i].center==mid[0] && a[i].dis<mid[1]); i++);
    if (i<=j) {
      temp=a[i], a[i]=a[j], a[j]=temp;
      i++, j--;
    }
  }
  if (i<r) {
    sort(a, i, r);
  }
  if (j>l) {
    sort(a, l, j);
  }
}

int max(int a, int b) {
  return a>b ? a : b;
}

int main() {
  freopen("rotate.in", "r", stdin);
  freopen("rotate.out", "w", stdout);

  static Card card[maxn+1];
  static int pre[maxn+1], suf[maxn+1];
  int n;
  scanf("%d", &n);
  for (int i=1; i<=n; i++) {
    int t;
    scanf("%d", &t);
    pre[i] = pre[i-1]+(t==i);
    suf[i] = t==i;
    card[i].center = (double)(t+i)/2;
    card[i].dis = abs(card[i].center-i);
  }
  for (int i=n; i>0; i--) {
    suf[i] += suf[i+1];
  }

  sort(card, 1, n);

  int ans=pre[n], now=0;
  for (int i=1; i<=n; i++) {
    if (card[i].center!=card[i-1].center) {
      now=0;
    }
    now++;
    ans = max(ans, now+pre[(int)(card[i].center-card[i].dis)-1]+suf[(int)(card[i].center+card[i].dis)+1]);
  }
  printf("%d", ans);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
